using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class NPD_NoteMap : EntityTypeConfiguration<NPD_Note>
    {
        public NPD_NoteMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Subject)
                .HasMaxLength(100);

            this.Property(t => t.RecordType)
                .HasMaxLength(30);

            this.Property(t => t.RecordID)
                .HasMaxLength(30);

            this.Property(t => t.Status)
                .HasMaxLength(2);

            this.Property(t => t.EstDuration)
                .HasMaxLength(10);

            this.Property(t => t.ActualDuration)
                .HasMaxLength(10);

            this.Property(t => t.Priority)
                .HasMaxLength(2);

            // Table & Column Mappings
            this.ToTable("NPD_Note");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Subject).HasColumnName("Subject");
            this.Property(t => t.RecordType).HasColumnName("RecordType");
            this.Property(t => t.RecordID).HasColumnName("RecordID");
            this.Property(t => t.CreatedBy).HasColumnName("CreatedBy");
            this.Property(t => t.CreatedOn).HasColumnName("CreatedOn");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Confidential).HasColumnName("Confidential");
            this.Property(t => t.Alert).HasColumnName("Alert");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Progress).HasColumnName("Progress");
            this.Property(t => t.RequiredFrom).HasColumnName("RequiredFrom");
            this.Property(t => t.EstStartDate).HasColumnName("EstStartDate");
            this.Property(t => t.ActualStartDate).HasColumnName("ActualStartDate");
            this.Property(t => t.EstDuration).HasColumnName("EstDuration");
            this.Property(t => t.ActualDuration).HasColumnName("ActualDuration");
            this.Property(t => t.EstEndDate).HasColumnName("EstEndDate");
            this.Property(t => t.ActualEndDate).HasColumnName("ActualEndDate");
            this.Property(t => t.Priority).HasColumnName("Priority");

            // Relationships
            this.HasOptional(t => t.ACT_Progress)
                .WithMany(t => t.NPD_Note)
                .HasForeignKey(d => d.Progress);
            this.HasOptional(t => t.Name)
                .WithMany(t => t.NPD_Note)
                .HasForeignKey(d => d.CreatedBy);

        }
    }
}
